package com.dream.testtubebaby_doctor.utils;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class DBHelper extends SQLiteOpenHelper {
	private static final String DB_NAME = "testtube_doctor_app_data";

	private static DBHelper mDbHelper = null;

	public static DBHelper getInstance(Context context) {
		if (mDbHelper == null) {
			synchronized (DBHelper.class) {
				if (mDbHelper == null) {
					mDbHelper = new DBHelper(context);
				}
			}
		}
		return mDbHelper;
	}

	private DBHelper(Context context) {
		super(context, DB_NAME, null, 1);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		//bbs table
		String sql = "create table tb_bbsItem( _id integer primary key autoincrement , "
				+ " title text , viewCount integer , replyCount integer , postUserName text , postDate integer , content text , bbstype integer  );";
		db.execSQL(sql);
		//told table
		String sql1 = "create table tb_toldItem( _id integer primary key autoincrement , "
				+ " doctorid integer , fromtime text , totime text , stepname text , f_steptodo integer , drug text , howmuch text , f_finished integer , finishtime integer);";
		db.execSQL(sql1);
		
		//shopping cart table
		String sql2 = "create table tb_spctItem( _id integer primary key autoincrement , "
				+ " product_id integer , iconurl text , product_name text , product_price integer , product_num integer , product_dec text);";
		db.execSQL(sql2);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

	}

}
